<?php
namespace App\Library;

class MyCrypt {
    private $key;
    private $iv;

    function __construct() {
        $salt      = 'mzc_sms';
        $this->key = hash('sha256', $salt, true);
        $this->iv  = mcrypt_create_iv(32);
    }

    function encrypt($input) {
        return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->key, $input, MCRYPT_MODE_ECB, $this->iv));
    }

    function decrypt($input) {
        return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->key, base64_decode($input), MCRYPT_MODE_ECB, $this->iv));
    }
}
